﻿/*======================================================================
== Copyright : BlueCurve (c)
== Licence   : Gnu/GPL v2.x
== Author    : Teddy Albina
== Email     : bluecurveteam@gmail.com
== Web site  : http://www.codeplex.com/BlueCurve
========================================================================*/
using System;
using System.Text;
using BlueCurve.AddinHostView;
using BlueCurve.Plugins;
using System.AddIn.Pipeline;
using BlueCurve.IndexationContract;
using BlueCurve.WebCrawlerRequest;
using System.Security.Cryptography.X509Certificates;
using BlueCurve.DownloadAttributes;


namespace BlueCurve.AddinHostAdapters
{
    /// <summary>
    /// Adapteur coté hote pour les plugins de type fichier
    /// </summary>
    [HostAdapter]
    public class AddinHostAdapterToAddinFile : AddinFileViewHostSide
    {
        private IFile _contract;
        private ContractHandle _handle;

        public AddinHostAdapterToAddinFile(IFile contract)
        {
            this._contract = contract;
            this._handle = new ContractHandle(contract);
        }

        public override IndexationData IndexerLoader(RequestState requeststate, string location)
        {
            return this._contract.IndexerLoader(requeststate, location);
        }
    }

    /// <summary>
    /// Adapteur coté hote pour les plugins de type protocol
    /// </summary>
    [HostAdapter]
    public class AddinHostAdapterToAddinProtocol : AddinProtocolViewHostSide
    {
        private IProtocol _contract;
        private ContractHandle _handle;

        public AddinHostAdapterToAddinProtocol(IProtocol contract)
        {
            this._contract = contract;
            this._handle = new ContractHandle(contract);
        }


        public override string Accept
        {
            get
            {
                return this._contract.Accept;
            }
            set
            {
                this._contract.Accept = value;
            }
        }

        public override Uri Proxy
        {
            get
            {
                return this._contract.Proxy;
            }
            set
            {
                this._contract.Proxy = value;
            }
        }

        public override RequestState Download(Attributes downloadata, X509Certificate[] certificates, X509Certificate[] certificates2)
        {
            return this._contract.Download(downloadata, certificates, certificates2);
        }
    }
}